package com.fenghongzhang.day014.util;

import android.database.sqlite.SQLiteDatabase;

import com.fenghongzhang.day014.App;
import com.fenghongzhang.day014.db.DaoMaster;
import com.fenghongzhang.day014.db.DaoSession;

public class DaoManager {

    private DaoSession daoSession;
    private static DaoManager daoManger;
    private DaoManager(){
        DaoMaster.DevOpenHelper devOpenHelper = new DaoMaster.DevOpenHelper(App.context, "search.db");
        SQLiteDatabase writableDatabase = devOpenHelper.getWritableDatabase();//
        DaoMaster daoMaster = new DaoMaster(writableDatabase);
        daoSession = daoMaster.newSession();
    }
    public static DaoManager getInstance(){
        if(daoManger == null){
            synchronized (DaoManager.class){
                if(daoManger == null){
                    daoManger = new DaoManager();
                }
            }
        }
        return daoManger;
    }

    public DaoSession getDaoSession() {
        return daoSession;
    }
}
